<template>
	<view class="confirm-order">
		<block v-if="detail!=''">
		<view class="inner">
			<view class="goods-row-top">
				<view class="rows">
					<view class="row">
						<text class="left">出售种类</text>
						<text class="right">{{detail.name}}</text>
					</view>
					<view class="row">
						<text class="left">出售数量</text>
						<text class="right">{{detail.money}}张</text>
					</view>
					<view class="row">
						<text class="left">出售单价</text>
						<text class="right">{{detail.jy_price}}元</text>
					</view>
					<view class="row">
						<text class="left">出售总价</text>
						<text class="right">{{detail.amount}}元</text>
					</view>
					<view class="row">
						<text class="left">扣服务费</text>
						<text class="right">{{detail.jy_sxf}}元</text>
					</view>
					<view class="row">
						<text class="left">订单状态</text>
						<text class="right">{{detail.status_text}}</text>
					</view>
					<view class="row">
						<text class="left">创建时间</text>
						<text class="right">{{detail.time_text}}</text>
					</view>
				</view>
			</view>
			<button type="default" class="submit-btn" :disabled="btnDisabled" @click="tijiao" v-if="detail.status==-1">取消</button>
		</view>
		</block>
		<u-popup :safeAreaInsetBottom="false" :safeAreaInsetTop="false" mode="center" :show="show" round="5"
			:overlay="true" :customStyle="customStyle1" @close="show=false">
			<view class="u-popup-slot">
				<text class="u-popup-slot_text">确认取消？</text>
				<view class="u-popup-slot_flex">
					<button @click="show = !show" class="cancel">取消</button>
					<button @click="confirm_cancel()" class="confirm">确认</button>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	var _this;
	export default {
		data() {
			return {
				form:{
					id:0,
				},
				customStyle1: {
					'width': '80%'
				},
				show:false,
				temp_index:-1,
				btnDisabled:false,
				detail:'',
				pay_list:[]
			};
		},
		onLoad(e) {
			_this=this;
			if(e.id){
				_this.form.id=e.id
			}
			if(e.index){
				_this.temp_index=e.index
			}
			_this.user_jy_xq()
		},
		methods:{
			tijiao(){
				_this.show=true
			},
			async confirm_cancel(){
				_this.btnDisabled=true
				const params = {
					id: _this.detail.id
				}
				const data = await _this.$post('api/user_jy_qx',params)
				if(data.code==200){
					uni.$u.toast(data.msg)
					uni.$emit('dealCancel',_this.temp_index)
					_this.detail.status=3
					_this.detail.status_text='已取消'
					_this.show=false
				}else{
					uni.$u.toast(data.msg)
				}
				setTimeout(()=>{
					_this.btnDisabled=false
				},2000)
			},
			async user_jy_xq() {
				const data = await _this.$post('api/user_jy_xq',_this.form)
				if(data.code==100){
					uni.$u.toast(data.msg)
					setTimeout(()=>{
						uni.navigateBack({})
					},2000)
				}else if(data.code==200){
					this.detail = data.data.detail
					this.pay_list = data.data.pay_list
				}else{
					uni.$u.toast(data.msg)
				}
			}
		},
		onShow() {},
	}
</script>

<style lang="scss" scoped>
	@import "@/static/css/order.scss";
	.confirm-order{
		.inner{}
	}
</style>